package com.pearl.jacksoncore.demo.databind.anno;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.*;
import com.fasterxml.jackson.databind.ser.std.RawSerializer;
import com.pearl.jacksoncore.demo.databind.custom.JsonListToCommaSplitString;
import com.pearl.jacksoncore.demo.databind.custom.ListToStringJsonDeserializer;
import com.pearl.jacksoncore.demo.databind.custom.ListToStringJsonSerializer;

import java.lang.reflect.MalformedParametersException;
import java.lang.reflect.Parameter;

/**
 * @author TD
 * @version 1.0
 * @date 2024/4/15
 */
public class MyAnnotationIntrospector extends NopAnnotationIntrospector {
    private static final long serialVersionUID = 1L;

    public static final MyAnnotationIntrospector instance = new MyAnnotationIntrospector();


    @Override
    public Object findSerializer(Annotated a) {
        JsonListToCommaSplitString ann = (JsonListToCommaSplitString) this._findAnnotation(a, JsonListToCommaSplitString.class);
        if (ann != null) {
            return ListToStringJsonSerializer.instance;
        }
        return null;
    }

    @Override
    public Object findDeserializer(Annotated a) {
        JsonListToCommaSplitString ann = (JsonListToCommaSplitString) this._findAnnotation(a, JsonListToCommaSplitString.class);
        if (ann != null) {
            return ListToStringJsonDeserializer.instance;
        }
        return null;
    }
}

